home *** CD-ROM | disk | FTP | other *** search
- ;OCL{{{}}}
- ;OCL{{{ comments
- ; this macro package can read/savte the kill-/delete- and move-buffer from/to
- ; files. Therefor it must enter a filed fold, so that the currently edited
- ; file will be saved.
- ; If no tag DUMP-FILE is set, the file `~/.origamibuf' is used. Otherwise
- ; you have to define a macro 'dump-file', which generates the filename on a
- ; empty text-line.
- ;OCL}}}
- @if-using not(ocl-file-file-buffers)
- @use (ocl-file-file-buffers)
- ;OCL{{{ libs
- @if-using not(ocl-file-error) @lib error @fi
- @if-using not(ocl-file-hide-buffer) @lib hide-buffer @fi
- ;OCL}}}
- ;OCL{{{ bf-action
- @if-using not(DUMP-FILE)
- ;OCL{{{ dump-file
- ( defmac dump-file ( "~ insert-ascii path-separator ".origamibuf ) )
- ;OCL}}}
- @fi
- ( defvar ( bf-save bf-error bf-buff-id bf-dummy-buff-id ) )
-
- ( deffun bf-action
- ( if in-prompt ( return-from-macro ) fi
- set bf-buff-id current-buffer-id
- open-hidden-dummy-buffer(false)
- set bf-dummy-buff-id current-buffer-id
- ;OCL{{{ save the buffers to dummy-buffer
- ;OCL{{{ set language
- if not(test-language Inmos) ( set-language Inmos ) fi
- ;OCL}}}
- ;OCL{{{ move
- beginning-of-line create-fold create-fold "move
- enter-fold move-line exit-fold
- ;OCL}}}
- ;OCL{{{ delete
- beginning-of-line create-fold create-fold "delete
- enter-fold
- ;OCL{{{ undelete all lines
- if last-message M_NO_UNDEL () fi
- do
- ( undo-delete-line )
- while not(last-message M_NO_UNDEL)
- ;OCL}}}
- exit-fold
- ;OCL}}}
- ;OCL{{{ kill
- beginning-of-line create-fold create-fold "kill
- enter-fold insert-folded-kill-buffer unfold-fold exit-fold
- ;OCL}}}
- ;OCL}}}
- if last-message M_CANTOPEN () fi
- if last-message M_CANTWRITE () fi
- if bf-save
- ;OCL{{{ save file
- ( write-file dump-file newline-and-indent )
- ;OCL}}}
- else
- ;OCL{{{ try to insert the saved buffers to the beginning of the file!
- ( beginning-of-fold
- next-line
- insert-file dump-file newline-and-indent
- )
- ;OCL}}}
- fi
- set bf-error
- counter or (last-message M_CANTOPEN last-message M_CANTWRITE)
- ;OCL{{{ read the buffers
- local
- ()
- ( beginning-of-fold
- next-line
- if test-fold-line
- ( enter-fold
- while not( test-end-fold ) ( kill-line )
- exit-fold
- next-line
- if test-fold-line
- ( enter-fold
- while not(test-bottom) ( delete-line )
- exit-fold
- next-line
- if test-fold-line
- ( enter-fold
- move-line
- exit-fold
- return-from-macro
- )
- fi
- )
- fi
- )
- fi
- set bf-error true
- )
- ;OCL}}}
- leave-hidden-dummy-buffer(bf-buff-id)
- set bf-dummy-buff-id current-buffer-id
- redraw-display
- if bf-error ( message ( M_FAILED ) ) fi
- )
- )
- ;OCL}}}
- ;OCL{{{ dump-buffers-to-file
- ( deffun dump-buffers-to-file ( set bf-save 1 bf-action ) )
- ;OCL}}}
- ;OCL{{{ get-buffers-from-file
- ( deffun get-buffers-from-file ( set bf-save 0 bf-action ) )
- ;OCL}}}
- ;OCL{{{ abort-hook-add
- @if-using not(ABORT-HOOK-ADD)
- @use (ABORT-HOOK-ADD)
- ( defmac abort-hook-add ( ) )
- @fi
- ( defmac abort-hook-add-saved ( abort-hook-add ) )
- ( undeclare ( abort-hook-add ) )
- ( defmac abort-hook-add
- ( abort-hook-add-saved
- if bf-dummy-buff-id
- ( goto-buffer-id bf-dummy-buff-id
- set-file-unchanged
- set bf-dummy-buff-id 0
- )
- fi
- )
- )
- ( undeclare ( abort-hook-add-saved ) )
- ;OCL}}}
- ;OCL{{{ undeclares
- ( undeclare
- ( bf-action
- bf-save
- bf-error
- bf-dummy-buff-id
- @if-using not( DUMP-FILE ) dump-file @fi
- )
- )
- ;OCL}}}
- @fi
-